package tool.plot

import java.io.File

import implicits.Implicits._
import shared.Pojo._
import tool.Pojo._
import tool.Tool
import tool.plot.AllPlot.RPlotB


/**
 * Created by yz on 27/9/2020
 */
object Cladogram extends CladogramT with RPlotB {

  def producePlotConfigFile(data: AllPlotData, workspaceDir: File, extraData: ExtraDataData) = {
    Tool.dataCoverConfigFile(data, workspaceDir, configFileName, configJsonFileName)
  }

  override def getCommand(data: AllPlotData, extraData: ExtraDataData): String = {
    val clasc = if(data.layout.clasc == "") "" else " --sub_clade " + data.layout.clasc
    val title = if(data.mainTitle == "") " --title ''" else s" --title '${data.mainTitle}' "

    s"""
       |python ${new File(Tool.pyPath, "plot_cladogram.py").unixPath}  lefse_LDA.xls lefse_LDA.cladogram.pdf --format pdf ${clasc} --expand_void_lev ${data.layout.claevl} --max_lev ${data.layout.claml} --clade_sep ${data.layout.clacs} --radial_start_lev ${data.layout.clarsl} --labeled_start_lev ${data.layout.clalstartl} --labeled_stop_lev ${data.layout.clalstopl} --abrv_start_lev ${data.layout.claastartl} --abrv_stop_lev ${data.layout.claastopl} --max_point_size ${data.layout.clamaxps} --min_point_size ${data.layout.claminps} --alpha ${data.font.claalpha} --point_edge_width ${data.font.clapew} --siblings_connector_width ${data.font.clascw} --parents_connector_width ${data.font.clapcw} --right_space_prop ${data.layout.clarsp} ${title} --title_font_size ${data.mainTitleFont} --label_font_size ${data.font.clalfs} --class_legend_font_size ${data.font.claclfs} --dpi 300 --class_legend_vis ${data.layout.claclv}
       |convert  -density 300 lefse_LDA.cladogram.pdf  lefse_LDA.cladogram.png
       |""".stripMargin
  }

  override def defaultPlotArg(tmpPlotData: AllPlotData): AllPlotData = {
    val initData = AllPlotData()
    tmpPlotData.copy(
      mainTitle = "Cladogram",
      mainTitleFont = "14"
    )
  }

}

